Skip to content

Conversation

@kro-cat
Copy link

@kro-cat kro-cat commented Aug 14, 2025

Rollback Plan

If a change needs to be reverted, we will publish an updated version of the library.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

Description

Removing an attribute from a CRD will remove the type information for that resource. Removing an attribute from an existing resource will generate a null value in the diff. This null value is used to unset the attribute in Kubernetes, but if the attribute doesn't exist, Kubernetes will ignore it without error. When validating a schema, if the type information doesn't exist, but the value to insert is null, then we can safely skip the "Attribute not found in schema" error.

The following samples have been added to TestMorphValueToType()

  • object -> object (null): A null attribute which doesn't exist in the type is specified in the value.
  • object -> object (deep null): A null attribute within a nested object which doesn't exist in the type is specified in the value.
  • object -> object (aggregate null): A null attribute within a nested object which doesn't exist in the type is specified in the value. All valid attributes of the nested object are null.

Acceptance tests

  • Have you added an acceptance test for the functionality being added? N/A - see below.
  • Added functionality test in TestMorphValueToType()
  • Have you run the acceptance tests on this branch? Full acceptance test suite.

Summary from acceptance testing:

NOTE: the following tests were re-run on their own due to timeout during initial testing:

  • TestAccKubernetesDeploymentV1_config_with_automount_service_account_token
  • TestAccKubernetesDeploymentV1_with_restart_policy
  • TestAccKubernetesPodV1_with_pod_anti_affinity_with_required_during_scheduling_ignored_during_execution
  • TestAccKubernetesPodV1_updateArgsForceNew
  • TestAccKubernetesPodV1_with_secret_vol_items
  • TestAccKubernetesPodV1_config_container_working_dir (Fails in hashicorp/terraform-provider-kubernetes/HEAD)
  • TestAccKubernetesPodV1_config_container_startup_probe (Fails in hashicorp/terraform-provider-kubernetes/HEAD)
  • TestAccKubernetesPodV1_enableServiceLinks
  • TestAccKubernetesPodV1_os
  • TestAccKubernetesPodV1_with_volume_mount_sub_path_expr
$ make testacc TESTARGS='-run=TestAcc' PARALLEL_RUNS=3
which: no setenforce in ([REDACTED PATH])
==> Checking that code complies with gofmt requirements...
go vet ./...
TF_ACC=1 go test "/terraform-provider-kubernetes/kubernetes" -v -vet=off -run ^TestAcc -parallel 3 -timeout 3h
=== RUN   TestAccKubernetesDataSourceAllNamespaces_basic
=== PAUSE TestAccKubernetesDataSourceAllNamespaces_basic
=== RUN   TestAccKubernetesDataSourceConfigMapV1_basic
=== PAUSE TestAccKubernetesDataSourceConfigMapV1_basic
=== RUN   TestAccKubernetesDataSourceConfigMapV1_not_found
=== PAUSE TestAccKubernetesDataSourceConfigMapV1_not_found

... [logs truncated for brevity; skipped tests follow] ...

--- SKIP: TestAccKubernetesStatefulSetV1WIthVolumeDevice_basic_idempotency (0.00s)
--- SKIP: TestAccKubernetesValidatingWebhookConfigurationV1Beta1_basic (0.01s)
--- SKIP: TestAccKubernetesServiceV1_stringTargetPort (0.01s)
--- SKIP: TestAccKubernetesPersistentVolumeV1_azure_blobStorageDisk (0.00s)
--- SKIP: TestAccKubernetesStatefulSetV1WIthVolumeDevice_basic (0.00s)
--- SKIP: TestAccKubernetesPersistentVolumeV1_azure_ManagedDiskExpectErrors (0.00s)
--- SKIP: TestAccKubernetesPersistentVolumeV1_azure_basic (0.27s)
--- SKIP: TestAccKubernetesPersistentVolumeClaimV1_expansionMinikube (0.00s)
--- SKIP: TestAccKubernetesPersistentVolumeClaimV1_expansionGoogleCloud (0.00s)
--- SKIP: TestAccKubernetesPersistentVolumeClaimV1_googleCloud_storageClass (0.00s)
--- SKIP: TestAccKubernetesPersistentVolumeClaimV1_googleCloud_volumeUpdate (0.00s)
--- SKIP: TestAccKubernetesServiceV1_noTargetPort (0.01s)
--- SKIP: TestAccKubernetesPersistentVolumeClaimV1_googleCloud_volumeMatch (0.00s)
--- SKIP: TestAccKubernetesServiceV1_loadBalancer_annotations_aws (0.28s)
--- SKIP: TestAccKubernetesServiceV1_loadBalancer_healthcheck (0.13s)
--- SKIP: TestAccKubernetesServiceV1_loadBalancer_internal_traffic_policy (0.49s)
--- SKIP: TestAccKubernetesServiceV1_loadBalancer (0.30s)
--- SKIP: TestAccKubernetesServiceAccountV1_default_secret (0.01s)
--- SKIP: TestAccKubernetesIngressV1Beta1_WaitForLoadBalancerGoogleCloud (0.00s)
--- SKIP: TestAccKubernetesIngressV1Beta1_InternalKey (0.00s)
--- SKIP: TestAccKubernetesIngressV1Beta1_emptyTLS (0.00s)
--- SKIP: TestAccKubernetesIngressV1Beta1_TLS (0.00s)
--- SKIP: TestAccKubernetesIngressV1Beta1_basic (0.00s)
--- SKIP: TestAccKubernetesIngressV1_WaitForLoadBalancerGoogleCloud (0.01s)
--- SKIP: TestAccKubernetesHorizontalPodAutoscalerV2Beta2_containerResource (0.00s)
--- SKIP: TestAccKubernetesHorizontalPodAutoscalerV2Beta2_basic (0.01s)
--- SKIP: TestAccKubernetesHorizontalPodAutoscalerV2Beta2_minimal (0.01s)
--- SKIP: TestAccKubernetesPodV1_bug1085 (0.02s)
--- SKIP: TestAccKubernetesPodV1_gke_with_nodeSelector (0.00s)
--- SKIP: TestAccKubernetesPodV1_with_csi_volume_hostpath (0.05s)
--- SKIP: TestAccKubernetesPodSecurityPolicyV1Beta1_basic (0.01s)
--- SKIP: TestAccKubernetesPodDisruptionBudget_basic (0.01s)
--- SKIP: TestAccKubernetesCSIDriverV1Beta1_basic (0.01s)
--- SKIP: TestAccKubernetesPersistentVolumeV1_storageClass (2.46s)
--- SKIP: TestAccKubernetesCronJobV1Beta1_minimalWithTemplateNamespace (0.01s)
--- SKIP: TestAccKubernetesCronJobV1Beta1_basic (0.01s)
--- SKIP: TestAccKubernetesPersistentVolumeV1_googleCloud_volumeSource (0.00s)
--- SKIP: TestAccKubernetesPersistentVolumeV1_aws_basic (0.01s)
--- SKIP: TestAccKubernetesPersistentVolumeV1_googleCloud_basic (0.06s)
--- SKIP: TestAccKubernetesPersistentVolumeV1_azure_file (1.73s)
--- SKIP: TestAccKubernetesCronJobV1Beta1_extra (0.00s)
--- SKIP: TestAccKubernetesStorageClassV1_allowedTopologies_minikube (0.00s)
--- SKIP: TestAccKubernetesStorageClassV1_generatedName (0.00s)
--- SKIP: TestAccKubernetesStorageClassV1_minikube (0.00s)
--- SKIP: TestAccKubernetesStorageClassV1_basic (0.00s)
--- SKIP: TestAccKubernetesStorageClassV1_volumeExpansion (0.01s)
--- SKIP: TestAccKubernetesCertificateSigningRequestV1_awsBasic (1.31s)
--- SKIP: TestAccKubernetesCertificateSigningRequest_generateName (0.01s)
--- SKIP: TestAccKubernetesCertificateSigningRequest_basic (0.00s)
--- SKIP: TestAccKubernetesDataSourceStorageClassV1_gke (0.64s)
--- SKIP: TestAccKubernetesDataSourceStorageClassV1_minikube (0.42s)
--- SKIP: TestAccKubernetesDataSourceServiceAccountV1_default_secret (0.00s)
--- SKIP: TestAccKubernetesDataSourceIngress_not_found (0.01s)
--- SKIP: TestAccKubernetesDataSourceIngress_basic (0.01s)
--- SKIP: TestAccKubernetesStatefulSetV1WIthVolumeDevice_waitForRollout (0.35s)
--- SKIP: TestAccKubernetesStatefulSetV1WIthVolumeDevice_Update (0.06s)

... [failed tests follow] ...

=== NAME  TestAccKubernetesPodV1_config_container_startup_probe
    resource_kubernetes_pod_v1_test.go:1204: Step 1/2 error: Check failed: Check 2/6 error: kubernetes_pod_v1.test: Attribute 'metadata.0.generation' expected "0", got "1"
--- FAIL: TestAccKubernetesPodV1_config_container_startup_probe (50.61s)

=== NAME  TestAccKubernetesPodV1_config_container_working_dir
    resource_kubernetes_pod_v1_test.go:1166: Step 1/3 error: Check failed: Check 2/3 error: kubernetes_pod_v1.test: Attribute 'metadata.0.generation' expected "0", got "1"
--- FAIL: TestAccKubernetesPodV1_config_container_working_dir (33.88s)

... [logs truncated for brevity] ...

FAIL
FAIL	github.com/hashicorp/terraform-provider-kubernetes/kubernetes	3545.736s
FAIL
make: *** [GNUmakefile:78: testacc] Error 1
make testacc TESTARGS="-run ^TestAcc" PARALLEL_RUNS=3 2>&1  824.27s user 145.17s system 27% cpu 59:09.34 total

Output from functionality testing:

$ cd manifest && make test TESTARGS='-run=TestMorph'
go test -v -run ^TestMorph -timeout=30s -parallel=4 "./..."
?   	github.com/hashicorp/terraform-provider-kubernetes/manifest	[no test files]
=== RUN   TestMorphValueToType
=== RUN   TestMorphValueToType/string->number
=== RUN   TestMorphValueToType/list->list
=== RUN   TestMorphValueToType/map->map
=== RUN   TestMorphValueToType/bool(unkown_value)->bool
=== RUN   TestMorphValueToType/string(unkown_value)->number
=== RUN   TestMorphValueToType/number(unkown_value)->string
=== RUN   TestMorphValueToType/object_->_object_(null)
=== RUN   TestMorphValueToType/number->string
=== RUN   TestMorphValueToType/list->tuple
=== RUN   TestMorphValueToType/list->set
=== RUN   TestMorphValueToType/tuple->tuple
=== RUN   TestMorphValueToType/set->list
=== RUN   TestMorphValueToType/object_->_object
=== RUN   TestMorphValueToType/number->number
=== RUN   TestMorphValueToType/tuple(single)->tuple
=== RUN   TestMorphValueToType/set->tuple
=== RUN   TestMorphValueToType/map->object
=== RUN   TestMorphValueToType/string(unknown_value)->string
=== RUN   TestMorphValueToType/bool(unkown_value)->string
=== RUN   TestMorphValueToType/bool->string
=== RUN   TestMorphValueToType/tuple->set
=== RUN   TestMorphValueToType/tuple(object)->tuple(object)
=== RUN   TestMorphValueToType/object->object
=== RUN   TestMorphValueToType/string(unkown_value)->bool
=== RUN   TestMorphValueToType/object(dynamic)_->_object
=== RUN   TestMorphValueToType/tuple(object)->list(object)
=== RUN   TestMorphValueToType/object_->_object_(deep_null)
=== RUN   TestMorphValueToType/string->bool
=== RUN   TestMorphValueToType/bool->bool
=== RUN   TestMorphValueToType/tuple->list
=== RUN   TestMorphValueToType/object->map
=== RUN   TestMorphValueToType/number(unkown_value)->number
=== RUN   TestMorphValueToType/object_->_object_(aggregate_null)
=== RUN   TestMorphValueToType/string->string
--- PASS: TestMorphValueToType (0.01s)
    --- PASS: TestMorphValueToType/string->number (0.00s)
    --- PASS: TestMorphValueToType/list->list (0.00s)
    --- PASS: TestMorphValueToType/map->map (0.00s)
    --- PASS: TestMorphValueToType/bool(unkown_value)->bool (0.00s)
    --- PASS: TestMorphValueToType/string(unkown_value)->number (0.00s)
    --- PASS: TestMorphValueToType/number(unkown_value)->string (0.00s)
    --- PASS: TestMorphValueToType/object_->_object_(null) (0.00s)
    --- PASS: TestMorphValueToType/number->string (0.00s)
    --- PASS: TestMorphValueToType/list->tuple (0.00s)
    --- PASS: TestMorphValueToType/list->set (0.00s)
    --- PASS: TestMorphValueToType/tuple->tuple (0.00s)
    --- PASS: TestMorphValueToType/set->list (0.00s)
    --- PASS: TestMorphValueToType/object_->_object (0.00s)
    --- PASS: TestMorphValueToType/number->number (0.00s)
    --- PASS: TestMorphValueToType/tuple(single)->tuple (0.00s)
    --- PASS: TestMorphValueToType/set->tuple (0.00s)
    --- PASS: TestMorphValueToType/map->object (0.00s)
    --- PASS: TestMorphValueToType/string(unknown_value)->string (0.00s)
    --- PASS: TestMorphValueToType/bool(unkown_value)->string (0.00s)
    --- PASS: TestMorphValueToType/bool->string (0.00s)
    --- PASS: TestMorphValueToType/tuple->set (0.00s)
    --- PASS: TestMorphValueToType/tuple(object)->tuple(object) (0.00s)
    --- PASS: TestMorphValueToType/object->object (0.00s)
    --- PASS: TestMorphValueToType/string(unkown_value)->bool (0.00s)
    --- PASS: TestMorphValueToType/object(dynamic)_->_object (0.00s)
    --- PASS: TestMorphValueToType/tuple(object)->list(object) (0.00s)
    --- PASS: TestMorphValueToType/object_->_object_(deep_null) (0.00s)
    --- PASS: TestMorphValueToType/string->bool (0.00s)
    --- PASS: TestMorphValueToType/bool->bool (0.00s)
    --- PASS: TestMorphValueToType/tuple->list (0.00s)
    --- PASS: TestMorphValueToType/object->map (0.00s)
    --- PASS: TestMorphValueToType/number(unkown_value)->number (0.00s)
    --- PASS: TestMorphValueToType/object_->_object_(aggregate_null) (0.00s)
    --- PASS: TestMorphValueToType/string->string (0.00s)
=== RUN   TestMorphValueToTypeDiagnostics
=== RUN   TestMorphValueToTypeDiagnostics/object_->_object_(deep)
=== RUN   TestMorphValueToTypeDiagnostics/string->number
=== RUN   TestMorphValueToTypeDiagnostics/string->bool
=== RUN   TestMorphValueToTypeDiagnostics/bool->number
=== RUN   TestMorphValueToTypeDiagnostics/number->set[number]
=== RUN   TestMorphValueToTypeDiagnostics/list[string]->list[number]
=== RUN   TestMorphValueToTypeDiagnostics/object_->_object
--- PASS: TestMorphValueToTypeDiagnostics (0.00s)
    --- PASS: TestMorphValueToTypeDiagnostics/object_->_object_(deep) (0.00s)
    --- PASS: TestMorphValueToTypeDiagnostics/string->number (0.00s)
    --- PASS: TestMorphValueToTypeDiagnostics/string->bool (0.00s)
    --- PASS: TestMorphValueToTypeDiagnostics/bool->number (0.00s)
    --- PASS: TestMorphValueToTypeDiagnostics/number->set[number] (0.00s)
    --- PASS: TestMorphValueToTypeDiagnostics/list[string]->list[number] (0.00s)
    --- PASS: TestMorphValueToTypeDiagnostics/object_->_object (0.00s)
PASS
ok  	github.com/hashicorp/terraform-provider-kubernetes/manifest/morph	(cached)
testing: warning: no tests to run
PASS
ok  	github.com/hashicorp/terraform-provider-kubernetes/manifest/openapi	(cached) [no tests to run]
testing: warning: no tests to run
PASS
ok  	github.com/hashicorp/terraform-provider-kubernetes/manifest/payload	(cached) [no tests to run]
testing: warning: no tests to run
PASS
ok  	github.com/hashicorp/terraform-provider-kubernetes/manifest/provider	(cached) [no tests to run]
testing: warning: no tests to run
PASS
ok  	github.com/hashicorp/terraform-provider-kubernetes/manifest/test/logging	(cached) [no tests to run]
testing: warning: no tests to run
PASS
ok  	github.com/hashicorp/terraform-provider-kubernetes/manifest/test/plugintest	(cached) [no tests to run]
...

Release Note

Release note for CHANGELOG:

NONE
...

References

Fixes: #2126

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

@hashicorp-cla-app
Copy link

hashicorp-cla-app bot commented Aug 14, 2025

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added size/M and removed size/XS labels Aug 18, 2025
@kro-cat kro-cat marked this pull request as ready for review August 18, 2025 17:28
@kro-cat kro-cat requested a review from a team as a code owner August 18, 2025 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Warning: Attribute not found in schema" after updating CRD

1 participant